<template>
	<view class="container">

		<view class="use_item">
			<view class="title">
				工作类型
			</view>
			<input v-model="form.jobType" placeholder="请输入工作类型" placeholder-style="color:#CCCCCC;font-size:32rpx" />
			<image src="../../static/img/myCenter/arrowright.png" mode=""></image>
		</view>
		<view class="use_item">
			<view class="title">
				工作职位
			</view>
			<input v-model="form.job" placeholder="请输入工作职位" placeholder-style="color:#CCCCCC;font-size:32rpx" />
			<image src="../../static/img/myCenter/arrowright.png" mode=""></image>
		</view>

		<view class="use_item">
			<view class="title">
				开始时间
			</view>
				<picker mode="date" class="pickerbox" :value="sdate" :start="startDate" :end="endDate" @change="sdateChange">
					<view>{{sdate}}</view>
				</picker>
			
			<image src="../../static/img/myCenter/arrowright.png" mode=""></image>
		</view>
		<view class="use_item">
			<view class="title">
				结束时间
			</view>
			<picker mode="date" class="pickerbox" :value="edate" :start="startDate" :end="endDate" @change="edateChange">
				<view>{{edate}}</view>
			</picker>
			<image src="../../static/img/myCenter/arrowright.png" mode=""></image>
		</view>
		<view class="use_item">
			<view class="title">
				公司名称
			</view>
			<input v-model="form.company" placeholder="请输入公司名称" placeholder-style="color:#CCCCCC;font-size:32rpx" />
			<image src="../../static/img/myCenter/arrowright.png" mode=""></image>
		</view>
		<view class="use_item">
			<view class="title">
				工作城市
			</view>
			 <region-picker class="pickerbox" @change="region_change" :value="350104">
				<view class="picker">{{form.city}}</view>
			 </region-picker>
			<image src="../../static/img/myCenter/arrowright.png" mode=""></image>
		</view>
		<Blank></Blank>
		<view class="car_require">
			<view class="tip">
				工作描述
			</view>
			<textarea v-model="form.remark" placeholder-style="color:#BBBBBB" placeholder="请详细描述在公司的具体负责事项，项目贡献或业 绩..." maxlength="500"/>
		</view>
		<HandleBtn btnName="保存" @click.native="addeducation()" class="confirm_btn"></HandleBtn>

	</view>
</template>

<script>
	import Blank from "../../components/blank.vue"
	import HandleBtn from "../../components/handleBtn.vue"
	export default {
		components: {
			Blank,
			HandleBtn
		},
		data() {
			return {
				visible:true,
				array: ['北京', '上海', '广州', '四川', '香港'],
				index: 0, // 地址默认显示的下标
				sdate: '请选择开始时间',
				edate:'请选择结束时间',
				form:{
					jobType:"",
					job:"",
					beginTime:"",
					endTime:"",
					company:"",
					city:"请选择工作城市",
					remark :""
				},
			}
		},
		mounted(){
			
		},
		methods: {
			region_change(e){
				this.form.city = e.detail.value[1]
			},
			// 选择日期
			sdateChange(e) {
				this.sdate = e.target.value
				this.form.beginTime = e.target.value
			},
			edateChange(e) {
				this.edate = e.target.value
				this.form.endTime = e.target.value
			},
			//添加工作经历
			addeducation(){
				if(this.form.city == '请选择工作城市') {
					this.$utils.showLayer('请选择工作城市')
					return
				}
				this.$utils.requert({url:'companyAdd',data:this.form,type:'post'}).then(res=>{
						if(res.code === 1 ){
							this.$utils.showLayer(res.message)
							uni.navigateBack({
								delta:1
							})
						}else{    
							this.$utils.showLayer(res.message)
						}
					})
			},
			// 获取年月日信息
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
	
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		},
		computed: {
				startDate() {
					return this.getDate('start');
				},
				endDate() {
					return this.getDate('end');
				}
			},
	}
</script>
<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #fff;
	}
</style>

<style scoped>
	.container {
		width: 100%;
		height: 100%;
	}
.picker{
	font-size: 34rpx;
}
	.use_item {
		padding: 38rpx 0;
		margin:0 24rpx;
		box-sizing: border-box;
		border-bottom: 1rpx solid #e1e1e1;
		display: flex;
		align-items: center;
	}
	.use_item:nth-child(6){
		border-bottom: none;
	}

	.use_item .title {
		font-size: 32rpx;
		color: #868686;
		width: 50%;
	}

	.use_item input {
		font-size: 32rpx;
	}
	.use_item .pickerbox {
		font-size: 32rpx;
		flex: 1;
		text-align: right;
		padding-right: 30rpx;
	}
	.use_item image{
		width: 14rpx;
		height: 24rpx;
		margin-left: auto;
	}
	.tip{
		font-size: 32rpx;
		color: #333333;
		margin-bottom: 34rpx;
	}
	textarea{
		background-color: #f5f4f6;
		font-size: 28rpx;
		width: 100%;
		border-radius: 7rpx;
		padding:32rpx 24rpx;
		box-sizing: border-box;
	}
	.car_require {
		padding:50rpx 24rpx;
		box-sizing: border-box;
	}
	.car_image{
		padding:0 24rpx 50rpx;
		box-sizing: border-box;
	}
	.car_image .tip{
		display: flex;
	}
	.car_image .tip .no_require{
		font-size: 28rpx;
		color: #BBBBBB;
	}
	.car_image .package_img{
		width:200rpx;
		height: 200rpx;
		background-color: #f5f4f6;
		text-align: center;
	}
	.car_image .package_img image{
		width:79rpx;
		height: 76rpx;
		margin-top: 62rpx

	}
	.confirm_btn{
		margin-top: 46rpx;
		margin-bottom: 70rpx;
	}
</style>
